<template>
	<view>
		<uni-table border stripe>
			<uni-tr>
				<uni-th width="150rpx" align="center">设备ID</uni-th>
				<uni-th width="200rpx" align="center">设备名称</uni-th>
				<uni-th width="200rpx" filter-type="search"
					@filter-change="filtFactor" align="center">因子类型</uni-th>
				<uni-th width="100rpx" align="center">报警值</uni-th>
				<uni-th width="100rpx" align="center">限值</uni-th>
				<uni-th width="300rpx" align="center" sortable>记录时间</uni-th>
			</uni-tr>
				<uni-tr v-for="(item,index) in alarmDataList" :key="index" style="color: black;">
					<uni-td style="color:black" align="center">{{item.deviceId}}</uni-td>
					<uni-td style="color:black" align="center">{{item.deviceName}}</uni-td>
					<uni-td style="color:black" align="center">{{item.factorName}}</uni-td>
					<uni-td style="color:black" align="center">{{item.warnVlue}}</uni-td>
					<uni-td style="color:black" align="center">{{item.limitingValue}}</uni-td>
					<uni-td style="color:black" align="center">{{item.recordingTime}}</uni-td>
				</uni-tr>	
		</uni-table>
	</view>
</template>

<script>
	import indexApi from '@/api/index.js'
	export default {
		name: 'alarmDeviceList',
		data() {
			return {
				alarmDataList: [],
				foctorType:'',
			}
		},
		onLoad(option) {
			indexApi.listWarn({
				selectFlag: 1,
				deviceId: option.deviceId
			}).then(res => {
				this.alarmDataList = res.data.rows
			})
		},
		methods: {
			filtFactor(val) {
				switch (val.filter) {
				  case '噪声':
				    this.factorType = 'noise';
				    break;
				  case 'PM2.5':
				  case 'pm2.5':
				    this.factorType = 'pm2.5';
				    break;
				  case 'PM10':
				  case 'pm10':
				    this.factorType = 'pm10';
				    break;
				  case '温度':
				    this.factorType = 'tem';
				    break;
				  case '湿度':
				    this.factorType = 'hum';
				    break;
				  case '风力':
				    this.factorType = 'wp';
				    break;
				  case '风速':
				    this.factorType = 'ws';
				    break;
				  case '风向':
				    this.factorType = 'wd360';
				    break;
				  case '大气压':
				    this.factorType = 'atm';
				    break;
				  default:
				    this.factorType = '';
				}
				indexApi.listWarn({
					selectFlag: 2,
					factorName: this.factorType
				}).then(res => {
					this.alarmDataList = res.data.rows
				})
			}
		}
	}
</script>

<style>

</style>